<?php

/**
 * @author PeoneEr
 * @package aion personal cabinet v1.0
 * @copyright Aion Factory Inc. 2010-2011
 * @license GNU v3
 * @link Ai-Factory.ru && http://code.google.com/p/aionprivateofficev2
 */
require_once "core/application/models/mchangelanguage/mchangelanguage.php";
require_once "core/application/classes/errorClass.php";

class Cchangelanguage extends ChangeLanguage_Model {

    private static $_instance = NULL;
    public $_lang             = NULL;

    public static function getInstance() {
        if (is_null(self::$_instance)) {
            $class = __CLASS__;
            self::$_instance = new $class();
        }
        return self::$_instance;
    }

    private function catchLanguage() {
        /**
         *  Ловим язык из запроса
         */
        return $_POST['language'];
    }

    public function changeLanguage() {
        $this->_lang = $this->getLanguage();
        try {
            $this->setNewLanguage($this->catchLanguage());
            $this->redirect(0, "index?settings&what=setParams");
        } catch (Exception $e) {
            echo $e->getMessage();
            error::getInstance($this->_lang->language['defaultError']);
        }
    }

}

?>
